let { observable, observe, computed, autorun, when } = require("mobx");

class Person {
    @observable name = "js";
    @observable age = 9;
    @observable list = {
        id: "1",
        name: "2"
    }
    //手机号拼接
    @observable area = "010";
    @observable photo = "15945789456";

    @computed get home() {
        return this.area + "_" + this.photo
    }

}

let p1 = new Person();

setInterval(() => {
    p1.age++
}, 1000);

when(() => p1.age >= 18, () => {
    console.log(p1.age)
})

// 如果是下面的写法，就是取消监听, 永远不会执行，
let owhen = when(() => p1.age >= 18, () => {
    console.log(p1.age)
})
owhen()